<?php
/**
 * Created by PhpStorm.
 * User: Lzhy ysjywz@gmail.com
 * Date: 2019/8/13
 * Time: 3:03 PM
 */
namespace app\common\event;

class Tool
{
    /**
     * 生成随机字符串
     * @param int $len
     * @param int $type
     * @return string
     */
    public static function gStr($len = 10,$type = 3)
    {
        $str = '';
        if($type === 1 || $type === 3) {
            $str .= 1234567890;
        }
        if($type === 2 || $type === 3){
            $str .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
        }
        
        $_round = '';
        for($i = 0; $i < $len; $i++){
            $_round .= $str[rand(0,strlen($str) - 1)];
        }
        
        return $_round;
    }
}